﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FineUI.Examples
{
    public partial class admin_readdclass : System.Web.UI.Page
    {

        protected void SetInfom()
        {

            tbxClassName.Text = Session["CL_Id"].ToString();
            dropDownListClass.SelectedValue = Session["CL_Address"].ToString();
  
        
        
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] == null)
            {
                Response.Redirect("~/login.aspx");
            }
            if (!IsPostBack)
            {
                SetInfom();
            
            }


        }

        protected void btnAddClass_Click(object sender, EventArgs e)
        {


            if (tbxClassName.Text == "")
            {
                Alert.ShowInTop("请输入教室的名称!");
                return;
            }

            string currentClassName = tbxClassName.Text.ToString();
            Maticsoft.BLL.Class Class = new Maticsoft.BLL.Class();
            Maticsoft.Model.Class ClassInfom = new Maticsoft.Model.Class();
            if (!Class.Exists(currentClassName))
            {
                ClassInfom.CL_Id = currentClassName;
                ClassInfom.CL_Name = currentClassName;
                ClassInfom.CL_Address = dropDownListClass.SelectedValue.ToString();
                Class.Add(ClassInfom);
                Alert.ShowInTop("修改教室信息成功!");

            }
            else
            {
                Alert.ShowInTop("修改教室信息失败");
                return;
            }
            Response.Redirect("~/admin_updateclass.aspx");

        }
        
    }
}